<?php
namespace app\api\controller;

class InsuranceDetail extends Permission
{
    public function getList()
    {
        $page = isset($this->input_data['page']) ? $this->input_data['page'] : 1;
        $limit = isset($this->input_data['limit']) ? $this->input_data['limit'] : 15;
        $map = [];

        if( isset($this->input_data['offer_id']) && $this->input_data['offer_id'] > 0 ) $map['insurance_plan_offer_id'] = $this->input_data['offer_id'];
        if( isset($this->input_data['cate']) && $this->input_data['cate'] != '所有类型' ) $map['cate'] = $this->input_data['cate'];

        $total = db('InsuranceDetail')->where($map)->count();
        $rows = db('InsuranceDetail')->order('id', 'desc')->page($page,$limit)->where($map)->select();


        $list = [];
        foreach ($rows as $v) {
            
            $list[] = $v;
        }
        
        $data = [
            'total' => $total,
            'list' => $list
        ];
        $this->resSuc($data);
    }
    

}
